<template>
  <ContentWrap
    class="cursor-pointer card-item bg-[var(--app-content-bg-color)]! dark:bg-[var(--el-bg-color)]!"
  >
    <el-row :gutter="10">
      <el-col :xs="7" :sm="7" :md="7" :lg="7" :xl="7">
        <div class="flex justify-center pos-relative">
          <el-image :fit="'fill'" :src="user.avatar" />
          <!-- sex 1 男 2 女 0未知 -->
          <Icon
            v-if="user.sex == 1"
            :icon="'svg-icon:nan'"
            :color="'blue'"
            class="pos-absolute! right-0 bottom-0"
          />
          <Icon
            v-if="user.sex == 2"
            :icon="'svg-icon:nvxing'"
            :color="'pink'"
            class="pos-absolute! right-0 bottom-0"
          />
        </div>
      </el-col>
      <el-col :xs="17" :sm="17" :md="17" :lg="17" :xl="17">
        <div class="!h-full flex flex-col justify-center">
          <div>
            <div class="flex items-center justify-between">
              <div class="flex items-center">
                <el-text
                  :title="user.nickname"
                  truncated
                  class="custom-text-20 w-80px! c-[#11192d]! .dark:c-[#fff]!"
                >
                  {{ user.nickname }}
                </el-text>
                <!-- <el-text class="custom-text-20 c-[#11192d]! .dark:c-[#fff]!" truncated>
                  |{{ user.sex == 1 ? '男' : '女' }}
                </el-text> -->
              </div>

              <div class="flex items-center">
                <el-text class="custom-text-18" truncated>{{ user.id }} </el-text>
              </div>
            </div>
          </div>
          <div class="flex justify-between items-center mt-10px">
            <el-text class="custom-text-18" truncated>
              {{ phoneFormat(user.mobile) }}
            </el-text>
            <el-text truncated class="custom-text-16" v-if="user.birthdayRemind">{{
              user.nextBirthday ? formatDate(user.nextBirthday, 'MM-DD') : '空'
            }}</el-text>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
        <div class="custom-text-14 flex mt-10px justify-between items-center">
          <el-text truncated :title="`距今到店:${user.activeDays}天`">
            距今到店:{{ user.activeDays }}天
          </el-text>

          <el-text class="custom-text-14 w-100px" truncated :title="user.tenantName">
            {{ user.tenantName }}</el-text
          >

          <el-text truncated :title="'员工姓名'">{{ user.employee }} </el-text>
        </div>
      </el-col>
    </el-row>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { propTypes } from '@/utils/propTypes'
import { phoneFormat } from '@/utils/formatter'
import { formatDate } from '@/utils/formatTime'

defineOptions({ name: 'UserCard' })
defineProps({
  user: propTypes.object.def({
    avatar: 'https://assets2.meton.vip/images/avatar_female.png',
    nickname: '姓名|昵称',
    sex: 0,
    mobile: '18888888888',
    shop: '门店',
    employee: '员工',
    tiemToShop: 'xxx',
    id: '123456'
  })
})
</script>
<style lang="scss" scoped>
.card-item {
  border: 1px solid transparent !important;
  &:hover {
    border: 1px solid var(--el-color-primary) !important;
    background: var(--el-color-primary-light-9) !important;
  }
}
:deep(.el-image) {
  border-radius: 4px;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
}
:deep(.el-image__inner) {
  position: absolute !important;
}
</style>
